const fs = require('fs');
const path = require('path');
const dateFormat = require('dateformat')


const now = new Date();
const formattedDate = dateFormat(now, 'yyyy-mm-dd HH:MM:ss');
const LOG_FILE_PATH = path.join(__dirname, 'log.txt');


function writeLog(level, message) {
  const log = `[${level.toUpperCase()}] ${formattedDate}: ${message}\n`;
  fs.appendFileSync(LOG_FILE_PATH, log);
}

function logInfo(message) {
  writeLog('info', message);
}

function logError(message) {
  writeLog('error', message);
}

// 导出日志模块
module.exports = {
  logInfo,
  logError,
};
